home *** CD-ROM | disk | FTP | other *** search
- % Copyright (C) 2000 Aladdin Enterprises. All rights reserved.
- %
- % This software is licensed to a single customer by Artifex Software Inc.
- % under the terms of a specific OEM agreement.
-
- % $RCSfile: pdfeof.ps,v $ $Revision: 1.1 $
- % Patch to allow garbage on the end of PDF files.
-
- .currentglobal true .setglobal
- pdfdict begin
-
- % Skip backward over the %%EOF at the end of the PDF file.
- % We put this in a separate procedure so we can easily offer the option
- % of accepting garbage after the %%EOF, which the PDF specification
- % unambiguously forbids but which some applications (including, apparently,
- % Acrobat Distiller on the Macintosh) produce, and of accepting the
- % xref position on the same line as startxref.
- /findxref { % - findxref <xrefpos>
- PDFfile dup dup 0 setfileposition bytesavailable
- dup /PDFfilelen exch def
- % Find the last %%EOF string (within 2048 bytes)
- 2048 sub PDFoffset .max
- 2 copy setfileposition
- PDFfilelen exch sub string 1 index exch readstring pop {
- (\015%%EO) search { % Adobe can handle truncated key string
- pop pop % if found, keep searching 'post' string
- } {
- (\012%%EO) search
- { pop pop } { exit } ifelse % exit if neither string found
- } ifelse
- } loop
- PDFfilelen exch length sub 4 sub PDFoffset .max setfileposition
- % Now read the startxref and xref start position.
- prevline token not { null } if dup type /integertype eq {
- exch pop cvi % xref start position
- exch PDFfile exch setfileposition
- prevline (startxref) linene { findxreferror } if
- pop
- } { % else, this file has 'startxref #####' format
- (startxref) ne { findxreferror } if
- cvi % xref start position
- exch PDFfile exch setfileposition
- } ifelse
- } bind def
-
- end % pdfdict
- .setglobal
-